<?php
    if(isset($form['#farmer'])&& !empty($form['#farmer'])) {
        echo get_template_header_info($form['#farmer']);
    }
?>
<?php
if(isset($form['#addr_id'])&& !empty($form['#addr_id'])) {
    echo get_template_header_info($form['#addr_id'], 'village');
}
?>
<div class="hp-tab-newprd">
    <?php if(!empty($_GET['farmer_id'])){?>
        <img style="margin-left: 75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/farmer.png"/>
    <?php }else if(!empty($_GET['addr_id'])){ ?>
        <img style="margin-left: 75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/village.png"/>
    <?php }?>
    <ul class="j-sw-nav">
    <?php if(!$form['#farmer'] && !$form['#addr_id']){?>
        <li class="newprd-s1 tab-li on"><a href="<?php echo base_path();?>farmer/plant_info/list">查看</a></li>
        <?php if(user_access('add plant_info')){?>
        <li class="newprd-s2 tab-li"><a href="<?php echo base_path();?>farmer/plant_info/add">添加</a></li>
    <?php }
    }else if(isset($form['#addr_id'])&& !empty($form['#addr_id'])){
        echo get_tab($form['#addr_id'],'plant_info','village');
        ?>

    <?php }else if(isset($form['#farmer'])&& !empty($form['#farmer'])){?>
        <?php echo get_tab($form['#farmer'],'plant_info'); ?>
    <?php }?>
    </ul>
    <div class="newprd-s1">
        <div class="table-div">
            <div style="height: 17px; cursor: pointer"><span style="float:right; margin-right: 20px; font-size: 14px;font-weight: bold" class="openORclose">展开搜索</span></div>
            <div class="search-div" style="display: none;margin-bottom: 10px">
                <div class="small-select"><div class="search-label">请选年份:</div><?php print render($form['year']); ?></div>
                <?php  global $user;
                $user_info = _get_user_info($user->uid);
                 if ($user_info['role'] != '农户') {?>
                    <?php if(empty($form['#farmer']) && empty($form['#addr_id'])){?>
                         <?php  print _address_render_for_list($form);  ?>
                    <?php }?>
                    <div class="small-select max-big-input column" style="clear:both">
                        <div class="search-label">专项活动:</div><?php print render($form['special_activities']); ?>
                    </div>
                <?php }?>
                <div class="small-select small-input">
                    <div class="small-div"><div class="search-label">请选字段:</div><?php print render($form['field']); ?></div>
                </div>
                <div class="small-select small-input"style="clear: both">
                    <div style="float: left; width: 200px" ><div class="search-label">范围:</div><?php print render($form['min_number']); ?></div>
                    <?php print render($form['max_number']); ?>
                </div>
                <div class="small-select small-input column" style="clear:both">
                    <div class="search-label">作物:</div><?php print render($form['plant']); ?>
                </div>
                <div class="search-submit"><?php print render($form['submit']); ?></div>
            </div>
<!--            <img class="res-search" src='--><?php //echo base_path();?><!--sites/all/themes/tweme/images/images/stats.png'>-->
            <div class="stats-div"><span>种植信息统计结果</span></div>
            <div class="table-div">
                <div class="farmer-field" style="margin-top: 0px">
                    <div class="farmer-field-div">
                        <span>总条目:</span>
                        <span><?php echo $form['#stat']['#count']; ?>条</span>
                    </div>
                    <div class="farmer-field-div">
                        <span>总种植面积:</span>
                        <span><?php echo $form['#stat']['#sum_plant_area']; ?>亩</span>
                    </div>
                </div>
                <div class="farmer-field" style="margin-top: 0px">
                    <div class="farmer-field-div"><span>平均数据：</span></div></div>
                <div class="farmer-field" style="margin-top: 0px">
                    <div class="farmer-field-div">
                        <span>种子开销:</span>
                        <span><?php echo $form['#stat']['#avg_seed_cost']; ?>元</span>
                    </div>
                    <div class="farmer-field-div">
                        <span>肥料开销:</span>
                        <span><?php echo $form['#stat']['#avg_fertilizer_cost']; ?>元</span>
                    </div>
                    <div class="farmer-field-div">
                        <span>农药开销:</span>
                        <span><?php echo $form['#stat']['#avg_pesticide_cost']; ?>元</span>
                    </div>
                </div>
                <div class="farmer-field" style="margin-top: 0px">
                    <div class="farmer-field-div">
                        <span>农机开销:</span>
                        <span><?php echo $form['#stat']['#avg_machinery_cost']; ?>元</span>
                    </div>
                    <div class="farmer-field-div ">
                        <span>其他开销:</span>
                        <span><?php echo $form['#stat']['#avg_others_cost']; ?>元</span>
                    </div>
                    <div class="farmer-field-div">
                        <span>一般产量:</span>
                        <span><?php echo $form['#stat']['#avg_general_yield']; ?>千克</span>
                    </div>
                </div>
                <div class="farmer-field" style="margin-top: 0px">
                    <div class="farmer-field-div">
                        <span>其他收益:</span>
                        <span><?php echo $form['#stat']['#avg_other_yield']; ?>元</span>
                    </div>
                </div>
                <?php if(isset($form['#farmer'])&& !empty($form['#farmer'])){?>
                    <ul class="table-ul-li" style="float: right">
<!--                        <li><a href="--><?php //echo base_path(); ?><!--farmer/plant_info/list?farmer_id=--><?php //echo $form['#farmer']?><!--"  class="selected">列表</a></li>-->
                        <?php if(user_access('add plant_info')){?>
<!--                            <li>|</li>-->
                            <li><a href="<?php echo base_path(); ?>farmer/plant_info/add?farmer_id=<?php echo $form['#farmer']?>"  class="btn btn-primary">添加</a></li>
                        <?php } ?>
                    </ul>
                <?php }?>
                <?php if(isset($form['#addr_id'])&& !empty($form['#addr_id'])){?>
                    <ul class="table-ul-li" style="float: right">
<!--                        <li><a href="--><?php //echo base_path(); ?><!--farmer/plant_info/list?addr_id=--><?php //echo $form['#addr_id']?><!--"  class="selected">列表</a></li>-->
                        <?php if(user_access('add plant_info')){?>
<!--                            <li>|</li>-->
                            <li><a href="<?php echo base_path(); ?>farmer/plant_info/add?addr_id=<?php echo $form['#addr_id']?>" class="btn btn-primary">添加</a></li>
                        <?php } ?>
                    </ul>
                <?php }?>
            </div>


            <img class="res-search" src='<?php echo base_path();?>sites/all/themes/tweme/images/images/res.png'>
            <div class="table-div">
                <?php print render($form['table']); ?>
            </div>
        </div>
    </div>
</div>
<?php print drupal_render_children($form); ?>

